<?php
class CollPlanModel
{
    public function __construct()
    {
        $this->db = Yaf_Registry::get('db');
    }
    /**
     * 查询采集计划列表
     * @return mixed
     */
    public function selectCollPlan($start,$everyPage)
    {
        $sql = "select * from `collection_plan` limit {$start},{$everyPage}";
        return  $this->db->query($sql);
    }
    public function getAllCount()
    {
        $sql="select count(*) as `rows` from `collection_plan` ";
        return $this->db->query($sql);
    }

    public function del($id)
    {
        $sql = "delete from collection_plan where id='{$id}' ";
        return $this->db->query($sql);
    }

    public function add($info)
    {
        $sql="insert into collection_plan(`source_id`,`status`,`remark`,`create_time`,`end_time`) values('{$info['source_id']}','{$info['status']}','{$info["remark"]}',UNIX_TIMESTAMP('{$info["create_time"]}'),UNIX_TIMESTAMP('{$info["end_time"]}'))";
        return $this->db->query($sql);
    }

    public function edit($info, $id)
    {
        $sql = "update `collection_plan` set `source_id`='{$info['name']}',`status`='{$info['status']}',`remark`='{$info['remark']}',`create_time`=UNIX_TIMESTAMP('{$info['create_time']}'),`end_time`=UNIX_TIMESTAMP('{$info['end_time']}') WHERE `id`='{$id}'";
        return $this->db->query($sql);
    }
}
?>